package com.feeyo.monitor.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**日期工具类
 * @Author <a href="mailto:bliulei@variflight.com">liulei</a>
 * @Description Created by liulei on 2017/5/15 下午6:02.
 */
public class DateUtils {
	
	public static java.text.SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static java.text.SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
	
	public static String getHourlyStr(Date time){
		return sdf.format(time).substring(0, 13) + ":00:00";
	}
	
	public static Date getStandardDateTime(String timestamp) throws ParseException{
		return sdf.parse(timestamp);
	}

    public static String getUtcDateTimeStr(String timestamp) throws ParseException{
        Date stdDatetime = sdf.parse(timestamp);
        Date utcDatetime = org.apache.commons.lang3.time.DateUtils.addHours(stdDatetime, -8);
        return sdf.format(utcDatetime);
    }

    public static Long dateTimeToStamp(String s) throws ParseException{
        Date date = sdf.parse(s);
        return date.getTime()/1000;
    }

    public static String getStandardDateTimeStr(Date datetime){
	    return sdf.format(datetime);
    }

    public static String getStandardDateStr(Date datetime){
        return sdfDate.format(datetime);
    }
}
